home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / d3dtypes.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  31.3 KB  |  959 lines

  1. /*==========================================================================;
  2.  *
  3.  *  Copyright (C) 1995-1996 Microsoft Corporation.  All Rights Reserved.
  4.  *
  5.  *  File:       d3dtypes.h
  6.  *  Content:    Direct3D types include file
  7.  *
  8.  ***************************************************************************/
  9.  
  10. #ifndef _D3DTYPES_H_
  11. #define _D3DTYPES_H_
  12. #pragma option push -b
  13.  
  14. #ifndef _WIN32
  15. #include "subwtype.h"
  16. #else
  17. #include <windows.h>
  18. #endif
  19.  
  20. #include <ddraw.h>
  21.  
  22. #pragma pack(4)
  23.  
  24. #if defined(__cplusplus)
  25. extern "C"
  26. {
  27. #endif
  28.  
  29. /* D3DVALUE is the fundamental Direct3D fractional data type */
  30.  
  31. #define D3DVALP(val, prec) ((float)(val))
  32. #define D3DVAL(val) ((float)(val))
  33. typedef float D3DVALUE, *LPD3DVALUE;
  34. #define D3DDivide(a, b)    (float)((double) (a) / (double) (b))
  35. #define D3DMultiply(a, b)    ((a) * (b))
  36.  
  37. typedef LONG D3DFIXED;
  38.  
  39. #ifndef RGB_MAKE
  40. /*
  41.  * Format of CI colors is
  42.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  43.  *  |    alpha      |         color index           |   fraction    |
  44.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  45.  */
  46. #define CI_GETALPHA(ci)    ((ci) >> 24)
  47. #define CI_GETINDEX(ci)    (((ci) >> 8) & 0xffff)
  48. #define CI_GETFRACTION(ci) ((ci) & 0xff)
  49. #define CI_ROUNDINDEX(ci)  CI_GETINDEX((ci) + 0x80)
  50. #define CI_MASKALPHA(ci)   ((ci) & 0xffffff)
  51. #define CI_MAKE(a, i, f)    (((a) << 24) | ((i) << 8) | (f))
  52.  
  53. /*
  54.  * Format of RGBA colors is
  55.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  56.  *  |    alpha      |      red      |     green     |     blue      |
  57.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  58.  */
  59. #define RGBA_GETALPHA(rgb)      ((rgb) >> 24)
  60. #define RGBA_GETRED(rgb)        (((rgb) >> 16) & 0xff)
  61. #define RGBA_GETGREEN(rgb)      (((rgb) >> 8) & 0xff)
  62. #define RGBA_GETBLUE(rgb)       ((rgb) & 0xff)
  63. #define RGBA_MAKE(r, g, b, a)   ((D3DCOLOR) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)))
  64.  
  65. /* D3DRGB and D3DRGBA may be used as initialisers for D3DCOLORs
  66.  * The float values must be in the range 0..1
  67.  */
  68. #define D3DRGB(r, g, b) \
  69.     (0xff000000L | ( ((long)((r) * 255)) << 16) | (((long)((g) * 255)) << 8) | (long)((b) * 255))
  70. #define D3DRGBA(r, g, b, a) \
  71.     (   (((long)((a) * 255)) << 24) | (((long)((r) * 255)) << 16) \
  72.     |   (((long)((g) * 255)) << 8) | (long)((b) * 255) \
  73.     )
  74.  
  75. /*
  76.  * Format of RGB colors is
  77.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  78.  *  |    ignored    |      red      |     green     |     blue      |
  79.  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  80.  */
  81. #define RGB_GETRED(rgb)         (((rgb) >> 16) & 0xff)
  82. #define RGB_GETGREEN(rgb)       (((rgb) >> 8) & 0xff)
  83. #define RGB_GETBLUE(rgb)        ((rgb) & 0xff)
  84. #define RGBA_SETALPHA(rgba, x) (((x) << 24) | ((rgba) & 0x00ffffff))
  85. #define RGB_MAKE(r, g, b)       ((D3DCOLOR) (((r) << 16) | ((g) << 8) | (b)))
  86. #define RGBA_TORGB(rgba)       ((D3DCOLOR) ((rgba) & 0xffffff))
  87. #define RGB_TORGBA(rgb)        ((D3DCOLOR) ((rgb) | 0xff000000))
  88.  
  89. #endif
  90.  
  91. /*
  92.  * Flags for Enumerate functions
  93.  */
  94.  
  95. /*
  96.  * Stop the enumeration
  97.  */
  98. #define D3DENUMRET_CANCEL                        DDENUMRET_CANCEL
  99.  
  100. /*
  101.  * Continue the enumeration
  102.  */
  103. #define D3DENUMRET_OK                            DDENUMRET_OK
  104.  
  105. typedef HRESULT (WINAPI* LPD3DVALIDATECALLBACK)(LPVOID lpUserArg, DWORD dwOffset);
  106. typedef HRESULT (WINAPI* LPD3DENUMTEXTUREFORMATSCALLBACK)(LPDDSURFACEDESC lpDdsd, LPVOID lpContext);
  107.  
  108. typedef DWORD D3DCOLOR, D3DCOLOR, *LPD3DCOLOR;
  109.  
  110. typedef DWORD D3DMATERIALHANDLE, *LPD3DMATERIALHANDLE;
  111. typedef DWORD D3DTEXTUREHANDLE, *LPD3DTEXTUREHANDLE;
  112. typedef DWORD D3DMATRIXHANDLE, *LPD3DMATRIXHANDLE;
  113.  
  114. typedef struct _D3DCOLORVALUE {
  115.     union {
  116.         D3DVALUE r;
  117.         D3DVALUE dvR;
  118.     };
  119.     union {
  120.         D3DVALUE g;
  121.         D3DVALUE dvG;
  122.     };
  123.     union {
  124.         D3DVALUE b;
  125.         D3DVALUE dvB;
  126.     };
  127.     union {
  128.         D3DVALUE a;
  129.         D3DVALUE dvA;
  130.     };
  131. } D3DCOLORVALUE;
  132.  
  133. typedef struct _D3DRECT {
  134.     union {
  135.         LONG x1;
  136.         LONG lX1;
  137.     };
  138.     union {
  139.         LONG y1;
  140.         LONG lY1;
  141.     };
  142.     union {
  143.         LONG x2;
  144.         LONG lX2;
  145.     };
  146.     union {
  147.         LONG y2;
  148.         LONG lY2;
  149.     };
  150. } D3DRECT, *LPD3DRECT;
  151.  
  152. typedef struct _D3DVECTOR {
  153.     union {
  154.         D3DVALUE x;
  155.         D3DVALUE dvX;
  156.     };
  157.     union {
  158.         D3DVALUE y;
  159.         D3DVALUE dvY;
  160.     };
  161.     union {
  162.         D3DVALUE z;
  163.         D3DVALUE dvZ;
  164.     };
  165. } D3DVECTOR, *LPD3DVECTOR;
  166.  
  167.  
  168. /*
  169.  * Vertex data types supported in an ExecuteBuffer.
  170.  */
  171.  
  172. /*
  173.  * Homogeneous vertices
  174.  */
  175.  
  176. typedef struct _D3DHVERTEX {
  177.     DWORD           dwFlags;        /* Homogeneous clipping flags */
  178.     union {
  179.         D3DVALUE    hx;
  180.         D3DVALUE    dvHX;
  181.     };
  182.     union {
  183.         D3DVALUE    hy;
  184.         D3DVALUE    dvHY;
  185.     };
  186.     union {
  187.         D3DVALUE    hz;
  188.         D3DVALUE    dvHZ;
  189.     };
  190. } D3DHVERTEX, *LPD3DHVERTEX;
  191.  
  192. /*
  193.  * Transformed/lit vertices
  194.  */
  195. typedef struct _D3DTLVERTEX {
  196.     union {
  197.         D3DVALUE    sx;             /* Screen coordinates */
  198.         D3DVALUE    dvSX;
  199.     };
  200.     union {
  201.         D3DVALUE    sy;
  202.         D3DVALUE    dvSY;
  203.     };
  204.     union {
  205.         D3DVALUE    sz;
  206.         D3DVALUE    dvSZ;
  207.     };
  208.     union {
  209.         D3DVALUE    rhw;            /* Reciprocal of homogeneous w */
  210.         D3DVALUE    dvRHW;
  211.     };
  212.     union {
  213.         D3DCOLOR    color;          /* Vertex color */
  214.         D3DCOLOR    dcColor;
  215.     };
  216.     union {
  217.         D3DCOLOR    specular;       /* Specular component of vertex */
  218.         D3DCOLOR    dcSpecular;
  219.     };
  220.     union {
  221.         D3DVALUE    tu;             /* Texture coordinates */
  222.         D3DVALUE    dvTU;
  223.     };
  224.     union {
  225.         D3DVALUE    tv;
  226.         D3DVALUE    dvTV;
  227.     };
  228. } D3DTLVERTEX, *LPD3DTLVERTEX;
  229.  
  230. /*
  231.  * Untransformed/lit vertices
  232.  */
  233. typedef struct _D3DLVERTEX {
  234.     union {
  235.         D3DVALUE     x;             /* Homogeneous coordinates */
  236.         D3DVALUE     dvX;
  237.     };
  238.     union {
  239.         D3DVALUE     y;
  240.         D3DVALUE     dvY;
  241.     };
  242.     union {
  243.         D3DVALUE     z;
  244.         D3DVALUE     dvZ;
  245.     };
  246.     DWORD            dwReserved;
  247.     union {
  248.         D3DCOLOR     color;         /* Vertex color */
  249.         D3DCOLOR     dcColor;
  250.     };
  251.     union {
  252.         D3DCOLOR     specular;      /* Specular component of vertex */
  253.         D3DCOLOR     dcSpecular;
  254.     };
  255.     union {
  256.         D3DVALUE     tu;            /* Texture coordinates */
  257.         D3DVALUE     dvTU;
  258.     };
  259.     union {
  260.         D3DVALUE     tv;
  261.         D3DVALUE     dvTV;
  262.     };
  263. } D3DLVERTEX, *LPD3DLVERTEX;
  264.  
  265. /*
  266.  * Untransformed/unlit vertices
  267.  */
  268.  
  269. typedef struct _D3DVERTEX {
  270.     union {
  271.         D3DVALUE     x;             /* Homogeneous coordinates */
  272.         D3DVALUE     dvX;
  273.     };
  274.     union {
  275.         D3DVALUE     y;
  276.         D3DVALUE     dvY;
  277.     };
  278.     union {
  279.         D3DVALUE     z;
  280.         D3DVALUE     dvZ;
  281.     };
  282.     union {
  283.         D3DVALUE     nx;            /* Normal */
  284.         D3DVALUE     dvNX;
  285.     };
  286.     union {
  287.         D3DVALUE     ny;
  288.         D3DVALUE     dvNY;
  289.     };
  290.     union {
  291.         D3DVALUE     nz;
  292.         D3DVALUE     dvNZ;
  293.     };
  294.     union {
  295.         D3DVALUE     tu;            /* Texture coordinates */
  296.         D3DVALUE     dvTU;
  297.     };
  298.     union {
  299.         D3DVALUE     tv;
  300.         D3DVALUE     dvTV;
  301.     };
  302. } D3DVERTEX, *LPD3DVERTEX;
  303.  
  304. /*
  305.  * Matrix, viewport, and tranformation structures and definitions.
  306.  */
  307.  
  308. typedef struct _D3DMATRIX {
  309.     D3DVALUE        _11, _12, _13, _14;
  310.     D3DVALUE        _21, _22, _23, _24;
  311.     D3DVALUE        _31, _32, _33, _34;
  312.     D3DVALUE        _41, _42, _43, _44;
  313. } D3DMATRIX, *LPD3DMATRIX;
  314.  
  315. typedef struct _D3DVIEWPORT {
  316.     DWORD       dwSize;
  317.     DWORD       dwX;
  318.     DWORD       dwY;            /* Top left */
  319.     DWORD       dwWidth;
  320.     DWORD       dwHeight;       /* Dimensions */
  321.     D3DVALUE    dvScaleX;       /* Scale homogeneous to screen */
  322.     D3DVALUE    dvScaleY;       /* Scale homogeneous to screen */
  323.     D3DVALUE    dvMaxX;         /* Min/max homogeneous x coord */
  324.     D3DVALUE    dvMaxY;         /* Min/max homogeneous y coord */
  325.     D3DVALUE    dvMinZ;
  326.     D3DVALUE    dvMaxZ;         /* Min/max homogeneous z coord */
  327. } D3DVIEWPORT, *LPD3DVIEWPORT;
  328.  
  329. /*
  330.  * Values for clip fields.
  331.  */
  332. #define D3DCLIP_LEFT                            0x00000001L
  333. #define D3DCLIP_RIGHT                           0x00000002L
  334. #define D3DCLIP_TOP                             0x00000004L
  335. #define D3DCLIP_BOTTOM                          0x00000008L
  336. #define D3DCLIP_FRONT                           0x00000010L
  337. #define D3DCLIP_BACK                            0x00000020L
  338. #define D3DCLIP_GEN0                            0x00000040L
  339. #define D3DCLIP_GEN1                            0x00000080L
  340. #define D3DCLIP_GEN2                            0x00000100L
  341. #define D3DCLIP_GEN3                            0x00000200L
  342. #define D3DCLIP_GEN4                            0x00000400L
  343. #define D3DCLIP_GEN5                            0x00000800L
  344.  
  345. /*
  346.  * Values for d3d status.
  347.  */
  348. #define D3DSTATUS_CLIPUNIONLEFT                 D3DCLIP_LEFT
  349. #define D3DSTATUS_CLIPUNIONRIGHT                D3DCLIP_RIGHT
  350. #define D3DSTATUS_CLIPUNIONTOP                  D3DCLIP_TOP
  351. #define D3DSTATUS_CLIPUNIONBOTTOM               D3DCLIP_BOTTOM
  352. #define D3DSTATUS_CLIPUNIONFRONT                D3DCLIP_FRONT
  353. #define D3DSTATUS_CLIPUNIONBACK                 D3DCLIP_BACK
  354. #define D3DSTATUS_CLIPUNIONGEN0                 D3DCLIP_GEN0
  355. #define D3DSTATUS_CLIPUNIONGEN1                 D3DCLIP_GEN1
  356. #define D3DSTATUS_CLIPUNIONGEN2                 D3DCLIP_GEN2
  357. #define D3DSTATUS_CLIPUNIONGEN3                 D3DCLIP_GEN3
  358. #define D3DSTATUS_CLIPUNIONGEN4                 D3DCLIP_GEN4
  359. #define D3DSTATUS_CLIPUNIONGEN5                 D3DCLIP_GEN5
  360.  
  361. #define D3DSTATUS_CLIPINTERSECTIONLEFT          0x00001000L
  362. #define D3DSTATUS_CLIPINTERSECTIONRIGHT         0x00002000L
  363. #define D3DSTATUS_CLIPINTERSECTIONTOP           0x00004000L
  364. #define D3DSTATUS_CLIPINTERSECTIONBOTTOM        0x00008000L
  365. #define D3DSTATUS_CLIPINTERSECTIONFRONT         0x00010000L
  366. #define D3DSTATUS_CLIPINTERSECTIONBACK          0x00020000L
  367. #define D3DSTATUS_CLIPINTERSECTIONGEN0          0x00040000L
  368. #define D3DSTATUS_CLIPINTERSECTIONGEN1          0x00080000L
  369. #define D3DSTATUS_CLIPINTERSECTIONGEN2          0x00100000L
  370. #define D3DSTATUS_CLIPINTERSECTIONGEN3          0x00200000L
  371. #define D3DSTATUS_CLIPINTERSECTIONGEN4          0x00400000L
  372. #define D3DSTATUS_CLIPINTERSECTIONGEN5          0x00800000L
  373. #define D3DSTATUS_ZNOTVISIBLE                   0x01000000L
  374.  
  375. #define D3DSTATUS_CLIPUNIONALL  (               \
  376.             D3DSTATUS_CLIPUNIONLEFT     |       \
  377.             D3DSTATUS_CLIPUNIONRIGHT    |       \
  378.             D3DSTATUS_CLIPUNIONTOP      |       \
  379.             D3DSTATUS_CLIPUNIONBOTTOM   |       \
  380.             D3DSTATUS_CLIPUNIONFRONT    |       \
  381.             D3DSTATUS_CLIPUNIONBACK     |       \
  382.             D3DSTATUS_CLIPUNIONGEN0     |       \
  383.             D3DSTATUS_CLIPUNIONGEN1     |       \
  384.             D3DSTATUS_CLIPUNIONGEN2     |       \
  385.             D3DSTATUS_CLIPUNIONGEN3     |       \
  386.             D3DSTATUS_CLIPUNIONGEN4     |       \
  387.             D3DSTATUS_CLIPUNIONGEN5             \
  388.             )
  389.  
  390. #define D3DSTATUS_CLIPINTERSECTIONALL   (               \
  391.             D3DSTATUS_CLIPINTERSECTIONLEFT      |       \
  392.             D3DSTATUS_CLIPINTERSECTIONRIGHT     |       \
  393.             D3DSTATUS_CLIPINTERSECTIONTOP       |       \
  394.             D3DSTATUS_CLIPINTERSECTIONBOTTOM    |       \
  395.             D3DSTATUS_CLIPINTERSECTIONFRONT     |       \
  396.             D3DSTATUS_CLIPINTERSECTIONBACK      |       \
  397.             D3DSTATUS_CLIPINTERSECTIONGEN0      |       \
  398.             D3DSTATUS_CLIPINTERSECTIONGEN1      |       \
  399.             D3DSTATUS_CLIPINTERSECTIONGEN2      |       \
  400.             D3DSTATUS_CLIPINTERSECTIONGEN3      |       \
  401.             D3DSTATUS_CLIPINTERSECTIONGEN4      |       \
  402.             D3DSTATUS_CLIPINTERSECTIONGEN5              \
  403.             )
  404.  
  405. #define D3DSTATUS_DEFAULT       (                       \
  406.             D3DSTATUS_CLIPINTERSECTIONALL       |       \
  407.             D3DSTATUS_ZNOTVISIBLE)
  408.  
  409.  
  410. /*
  411.  * Options for direct transform calls
  412.  */
  413. #define D3DTRANSFORM_CLIPPED       0x00000001l
  414. #define D3DTRANSFORM_UNCLIPPED     0x00000002l
  415.  
  416. typedef struct _D3DTRANSFORMDATA {
  417.     DWORD           dwSize;
  418.     LPVOID          lpIn;           /* Input vertices */
  419.     DWORD           dwInSize;       /* Stride of input vertices */
  420.     LPVOID          lpOut;          /* Output vertices */
  421.     DWORD           dwOutSize;      /* Stride of output vertices */
  422.     LPD3DHVERTEX    lpHOut;         /* Output homogeneous vertices */
  423.     DWORD           dwClip;         /* Clipping hint */
  424.     DWORD           dwClipIntersection;
  425.     DWORD           dwClipUnion;    /* Union of all clip flags */
  426.     D3DRECT         drExtent;       /* Extent of transformed vertices */
  427. } D3DTRANSFORMDATA, *LPD3DTRANSFORMDATA;
  428.  
  429. /*
  430.  * Structure defining position and direction properties for lighting.
  431.  */
  432. typedef struct _D3DLIGHTINGELEMENT {
  433.     D3DVECTOR dvPosition;           /* Lightable point in model space */
  434.     D3DVECTOR dvNormal;             /* Normalised unit vector */
  435. } D3DLIGHTINGELEMENT, *LPD3DLIGHTINGELEMENT;
  436.  
  437. /*
  438.  * Structure defining material properties for lighting.
  439.  */
  440. typedef struct _D3DMATERIAL {
  441.     DWORD               dwSize;
  442.     union {
  443.         D3DCOLORVALUE   diffuse;        /* Diffuse color RGBA */
  444.         D3DCOLORVALUE   dcvDiffuse;
  445.     };
  446.     union {
  447.         D3DCOLORVALUE   ambient;        /* Ambient color RGB */
  448.         D3DCOLORVALUE   dcvAmbient;
  449.     };
  450.     union {
  451.         D3DCOLORVALUE   specular;       /* Specular 'shininess' */
  452.         D3DCOLORVALUE   dcvSpecular;
  453.     };
  454.     union {
  455.         D3DCOLORVALUE   emissive;       /* Emissive color RGB */
  456.         D3DCOLORVALUE   dcvEmissive;
  457.     };
  458.     union {
  459.         D3DVALUE        power;          /* Sharpness if specular highlight */
  460.         D3DVALUE        dvPower;
  461.     };
  462.     D3DTEXTUREHANDLE    hTexture;       /* Handle to texture map */
  463.     DWORD               dwRampSize;
  464. } D3DMATERIAL, *LPD3DMATERIAL;
  465.  
  466. typedef enum _D3DLIGHTTYPE {
  467.     D3DLIGHT_POINT          = 1,
  468.     D3DLIGHT_SPOT           = 2,
  469.     D3DLIGHT_DIRECTIONAL    = 3,
  470.     D3DLIGHT_PARALLELPOINT  = 4,
  471.     D3DLIGHT_GLSPOT         = 5,
  472. } D3DLIGHTTYPE;
  473.  
  474. /*
  475.  * Structure defining a light source and its properties.
  476.  */
  477. typedef struct _D3DLIGHT {
  478.     DWORD           dwSize;
  479.     D3DLIGHTTYPE    dltType;            /* Type of light source */
  480.     D3DCOLORVALUE   dcvColor;           /* Color of light */
  481.     D3DVECTOR       dvPosition;         /* Position in world space */
  482.     D3DVECTOR       dvDirection;        /* Direction in world space */
  483.     D3DVALUE        dvRange;            /* Cutoff range */
  484.     D3DVALUE        dvFalloff;          /* Falloff */
  485.     D3DVALUE        dvAttenuation0;     /* Constant attenuation */
  486.     D3DVALUE        dvAttenuation1;     /* Linear attenuation */
  487.     D3DVALUE        dvAttenuation2;     /* Quadratic attenuation */
  488.     D3DVALUE        dvTheta;            /* Inner angle of spotlight cone */
  489.     D3DVALUE        dvPhi;              /* Outer angle of spotlight cone */
  490. } D3DLIGHT, *LPD3DLIGHT;
  491.  
  492. typedef struct _D3DLIGHTDATA {
  493.     DWORD                dwSize;
  494.     LPD3DLIGHTINGELEMENT lpIn;          /* Input positions and normals */
  495.     DWORD                dwInSize;      /* Stride of input elements */
  496.     LPD3DTLVERTEX        lpOut;         /* Output colors */
  497.     DWORD                dwOutSize;     /* Stride of output colors */
  498. } D3DLIGHTDATA, *LPD3DLIGHTDATA;
  499.  
  500. typedef enum _D3DCOLORMODEL {
  501.     D3DCOLOR_MONO           = 1,
  502.     D3DCOLOR_RGB            = 2,
  503. } D3DCOLORMODEL;
  504.  
  505. /*
  506.  * Options for clearing
  507.  */
  508. #define D3DCLEAR_TARGET            0x00000001l /* Clear target surface */
  509. #define D3DCLEAR_ZBUFFER           0x00000002l /* Clear target z buffer */
  510.  
  511. /*
  512.  * Execute buffers are allocated via Direct3D.  These buffers may then
  513.  * be filled by the application with instructions to execute along with
  514.  * vertex data.
  515.  */
  516.  
  517. /*
  518.  * Supported op codes for execute instructions.
  519.  */
  520. typedef enum _D3DOPCODE {
  521.     D3DOP_POINT                 = 1,
  522.     D3DOP_LINE                  = 2,
  523.     D3DOP_TRIANGLE              = 3,
  524.     D3DOP_MATRIXLOAD            = 4,
  525.     D3DOP_MATRIXMULTIPLY        = 5,
  526.     D3DOP_STATETRANSFORM        = 6,
  527.     D3DOP_STATELIGHT            = 7,
  528.     D3DOP_STATERENDER           = 8,
  529.     D3DOP_PROCESSVERTICES       = 9,
  530.     D3DOP_TEXTURELOAD           = 10,
  531.     D3DOP_EXIT                  = 11,
  532.     D3DOP_BRANCHFORWARD         = 12,
  533.     D3DOP_SPAN                  = 13,
  534.     D3DOP_SETSTATUS             = 14,
  535. } D3DOPCODE;
  536.  
  537. typedef struct _D3DINSTRUCTION {
  538.     BYTE bOpcode;   /* Instruction opcode */
  539.     BYTE bSize;     /* Size of each instruction data unit */
  540.     WORD wCount;    /* Count of instruction data units to follow */
  541. } D3DINSTRUCTION, *LPD3DINSTRUCTION;
  542.  
  543. /*
  544.  * Structure for texture loads
  545.  */
  546. typedef struct _D3DTEXTURELOAD {
  547.     D3DTEXTUREHANDLE hDestTexture;
  548.     D3DTEXTUREHANDLE hSrcTexture;
  549. } D3DTEXTURELOAD, *LPD3DTEXTURELOAD;
  550.  
  551. /*
  552.  * Structure for picking
  553.  */
  554. typedef struct _D3DPICKRECORD {
  555.     BYTE     bOpcode;
  556.     BYTE     bPad;
  557.     DWORD    dwOffset;
  558.     D3DVALUE dvZ;
  559. } D3DPICKRECORD, *LPD3DPICKRECORD;
  560.  
  561. /*
  562.  * The following defines the rendering states which can be set in the
  563.  * execute buffer.
  564.  */
  565.  
  566. typedef enum _D3DSHADEMODE {
  567.     D3DSHADE_FLAT              = 1,
  568.     D3DSHADE_GOURAUD           = 2,
  569.     D3DSHADE_PHONG             = 3,
  570. } D3DSHADEMODE;
  571.  
  572. typedef enum _D3DFILLMODE {
  573.     D3DFILL_POINT              = 1,
  574.     D3DFILL_WIREFRAME          = 2,
  575.     D3DFILL_SOLID              = 3,
  576. } D3DFILLMODE;
  577.  
  578. typedef struct _D3DLINEPATTERN {
  579.     WORD        wRepeatFactor;
  580.     WORD        wLinePattern;
  581. } D3DLINEPATTERN;
  582.  
  583. typedef enum _D3DTEXTUREFILTER {
  584.     D3DFILTER_NEAREST          = 1,
  585.     D3DFILTER_LINEAR           = 2,
  586.     D3DFILTER_MIPNEAREST       = 3,
  587.     D3DFILTER_MIPLINEAR        = 4,
  588.     D3DFILTER_LINEARMIPNEAREST = 5,
  589.     D3DFILTER_LINEARMIPLINEAR  = 6,
  590. } D3DTEXTUREFILTER;
  591.  
  592. typedef enum _D3DBLEND {
  593.     D3DBLEND_ZERO              = 1,
  594.     D3DBLEND_ONE               = 2,
  595.     D3DBLEND_SRCCOLOR          = 3,
  596.     D3DBLEND_INVSRCCOLOR       = 4,
  597.     D3DBLEND_SRCALPHA          = 5,
  598.     D3DBLEND_INVSRCALPHA       = 6,
  599.     D3DBLEND_DESTALPHA         = 7,
  600.     D3DBLEND_INVDESTALPHA      = 8,
  601.     D3DBLEND_DESTCOLOR         = 9,
  602.     D3DBLEND_INVDESTCOLOR      = 10,
  603.     D3DBLEND_SRCALPHASAT       = 11,
  604.     D3DBLEND_BOTHSRCALPHA      = 12,
  605.     D3DBLEND_BOTHINVSRCALPHA   = 13,
  606. } D3DBLEND;
  607.  
  608. typedef enum _D3DTEXTUREBLEND {
  609.     D3DTBLEND_DECAL            = 1,
  610.     D3DTBLEND_MODULATE         = 2,
  611.     D3DTBLEND_DECALALPHA       = 3,
  612.     D3DTBLEND_MODULATEALPHA    = 4,
  613.     D3DTBLEND_DECALMASK        = 5,
  614.     D3DTBLEND_MODULATEMASK     = 6,
  615.     D3DTBLEND_COPY             = 7,
  616. } D3DTEXTUREBLEND;
  617.  
  618. typedef enum _D3DTEXTUREADDRESS {
  619.     D3DTADDRESS_WRAP           = 1,
  620.     D3DTADDRESS_MIRROR         = 2,
  621.     D3DTADDRESS_CLAMP          = 3,
  622. } D3DTEXTUREADDRESS;
  623.  
  624. typedef enum _D3DCULL {
  625.     D3DCULL_NONE               = 1,
  626.     D3DCULL_CW                 = 2,
  627.     D3DCULL_CCW                = 3,
  628. } D3DCULL;
  629.  
  630. typedef enum _D3DCMPFUNC {
  631.     D3DCMP_NEVER               = 1,
  632.     D3DCMP_LESS                = 2,
  633.     D3DCMP_EQUAL               = 3,
  634.     D3DCMP_LESSEQUAL           = 4,
  635.     D3DCMP_GREATER             = 5,
  636.     D3DCMP_NOTEQUAL            = 6,
  637.     D3DCMP_GREATEREQUAL        = 7,
  638.     D3DCMP_ALWAYS              = 8,
  639. } D3DCMPFUNC;
  640.  
  641. typedef enum _D3DFOGMODE {
  642.     D3DFOG_NONE                = 0,
  643.     D3DFOG_EXP                 = 1,
  644.     D3DFOG_EXP2                = 2,
  645.     D3DFOG_LINEAR              = 3
  646. } D3DFOGMODE;
  647.  
  648. /*
  649.  * Amount to add to a state to generate the override for that state.
  650.  */
  651. #define D3DSTATE_OVERRIDE_BIAS          256
  652.  
  653. /*
  654.  * A state which sets the override flag for the specified state type.
  655.  */
  656. #define D3DSTATE_OVERRIDE(type) ((DWORD) (type) + D3DSTATE_OVERRIDE_BIAS)
  657.  
  658. typedef enum _D3DTRANSFORMSTATETYPE {
  659.     D3DTRANSFORMSTATE_WORLD           = 1,
  660.     D3DTRANSFORMSTATE_VIEW            = 2,
  661.     D3DTRANSFORMSTATE_PROJECTION      = 3,
  662. } D3DTRANSFORMSTATETYPE;
  663.  
  664. typedef enum _D3DLIGHTSTATETYPE {
  665.     D3DLIGHTSTATE_MATERIAL            = 1,
  666.     D3DLIGHTSTATE_AMBIENT             = 2,
  667.     D3DLIGHTSTATE_COLORMODEL          = 3,
  668.     D3DLIGHTSTATE_FOGMODE             = 4,
  669.     D3DLIGHTSTATE_FOGSTART            = 5,
  670.     D3DLIGHTSTATE_FOGEND              = 6,
  671.     D3DLIGHTSTATE_FOGDENSITY          = 7,
  672. } D3DLIGHTSTATETYPE;
  673.  
  674. typedef enum _D3DRENDERSTATETYPE {
  675.     D3DRENDERSTATE_TEXTUREHANDLE      = 1,    /* Texture handle */
  676.     D3DRENDERSTATE_ANTIALIAS          = 2,    /* Antialiasing prim edges */
  677.     D3DRENDERSTATE_TEXTUREADDRESS     = 3,    /* D3DTEXTUREADDRESS      */
  678.     D3DRENDERSTATE_TEXTUREPERSPECTIVE = 4,    /* TRUE for perspective correction */
  679.     D3DRENDERSTATE_WRAPU              = 5,    /* TRUE for wrapping in u */
  680.     D3DRENDERSTATE_WRAPV              = 6,    /* TRUE for wrapping in v */
  681.     D3DRENDERSTATE_ZENABLE            = 7,    /* TRUE to enable z test */
  682.     D3DRENDERSTATE_FILLMODE           = 8,    /* D3DFILL_MODE            */
  683.     D3DRENDERSTATE_SHADEMODE          = 9,    /* D3DSHADEMODE */
  684.     D3DRENDERSTATE_LINEPATTERN        = 10,   /* D3DLINEPATTERN */
  685.     D3DRENDERSTATE_MONOENABLE         = 11,   /* TRUE to enable mono rasterization */
  686.     D3DRENDERSTATE_ROP2               = 12,   /* ROP2 */
  687.     D3DRENDERSTATE_PLANEMASK          = 13,   /* DWORD physical plane mask */
  688.     D3DRENDERSTATE_ZWRITEENABLE       = 14,   /* TRUE to enable z writes */
  689.     D3DRENDERSTATE_ALPHATESTENABLE    = 15,   /* TRUE to enable alpha tests */
  690.     D3DRENDERSTATE_LASTPIXEL          = 16,   /* TRUE for last-pixel on lines */
  691.     D3DRENDERSTATE_TEXTUREMAG         = 17,   /* D3DTEXTUREFILTER */
  692.     D3DRENDERSTATE_TEXTUREMIN         = 18,   /* D3DTEXTUREFILTER */
  693.     D3DRENDERSTATE_SRCBLEND           = 19,   /* D3DBLEND */
  694.     D3DRENDERSTATE_DESTBLEND          = 20,   /* D3DBLEND */
  695.     D3DRENDERSTATE_TEXTUREMAPBLEND    = 21,   /* D3DTEXTUREBLEND */
  696.     D3DRENDERSTATE_CULLMODE           = 22,   /* D3DCULL */
  697.     D3DRENDERSTATE_ZFUNC              = 23,   /* D3DCMPFUNC */
  698.     D3DRENDERSTATE_ALPHAREF           = 24,   /* D3DFIXED */
  699.     D3DRENDERSTATE_ALPHAFUNC          = 25,   /* D3DCMPFUNC */
  700.     D3DRENDERSTATE_DITHERENABLE       = 26,   /* TRUE to enable dithering */
  701.     D3DRENDERSTATE_BLENDENABLE        = 27,   /* TRUE to enable alpha blending */
  702.     D3DRENDERSTATE_FOGENABLE          = 28,   /* TRUE to enable fog */
  703.     D3DRENDERSTATE_SPECULARENABLE     = 29,   /* TRUE to enable specular */
  704.     D3DRENDERSTATE_ZVISIBLE           = 30,   /* TRUE to enable z checking */
  705.     D3DRENDERSTATE_SUBPIXEL           = 31,   /* TRUE to enable subpixel correction */
  706.     D3DRENDERSTATE_SUBPIXELX          = 32,   /* TRUE to enable correction in X only */
  707.     D3DRENDERSTATE_STIPPLEDALPHA      = 33,   /* TRUE to enable stippled alpha */
  708.     D3DRENDERSTATE_FOGCOLOR           = 34,   /* D3DCOLOR */
  709.     D3DRENDERSTATE_FOGTABLEMODE       = 35,   /* D3DFOGMODE */
  710.     D3DRENDERSTATE_FOGTABLESTART      = 36,   /* Fog table start        */
  711.     D3DRENDERSTATE_FOGTABLEEND        = 37,   /* Fog table end          */
  712.     D3DRENDERSTATE_FOGTABLEDENSITY    = 38,   /* Fog table density      */
  713.     D3DRENDERSTATE_STIPPLEENABLE      = 39,   /* TRUE to enable stippling */
  714.     D3DRENDERSTATE_STIPPLEPATTERN00   = 64,   /* Stipple pattern 01...  */      
  715.     D3DRENDERSTATE_STIPPLEPATTERN01   = 65,
  716.     D3DRENDERSTATE_STIPPLEPATTERN02   = 66,
  717.     D3DRENDERSTATE_STIPPLEPATTERN03   = 67,
  718.     D3DRENDERSTATE_STIPPLEPATTERN04   = 68,
  719.     D3DRENDERSTATE_STIPPLEPATTERN05   = 69,
  720.     D3DRENDERSTATE_STIPPLEPATTERN06   = 70,
  721.     D3DRENDERSTATE_STIPPLEPATTERN07   = 71,
  722.     D3DRENDERSTATE_STIPPLEPATTERN08   = 72,
  723.     D3DRENDERSTATE_STIPPLEPATTERN09   = 73,
  724.     D3DRENDERSTATE_STIPPLEPATTERN10   = 74,
  725.     D3DRENDERSTATE_STIPPLEPATTERN11   = 75,
  726.     D3DRENDERSTATE_STIPPLEPATTERN12   = 76,
  727.     D3DRENDERSTATE_STIPPLEPATTERN13   = 77,
  728.     D3DRENDERSTATE_STIPPLEPATTERN14   = 78,
  729.     D3DRENDERSTATE_STIPPLEPATTERN15   = 79,
  730.     D3DRENDERSTATE_STIPPLEPATTERN16   = 80,
  731.     D3DRENDERSTATE_STIPPLEPATTERN17   = 81,
  732.     D3DRENDERSTATE_STIPPLEPATTERN18   = 82,
  733.     D3DRENDERSTATE_STIPPLEPATTERN19   = 83,
  734.     D3DRENDERSTATE_STIPPLEPATTERN20   = 84,
  735.     D3DRENDERSTATE_STIPPLEPATTERN21   = 85,
  736.     D3DRENDERSTATE_STIPPLEPATTERN22   = 86,
  737.     D3DRENDERSTATE_STIPPLEPATTERN23   = 87,
  738.     D3DRENDERSTATE_STIPPLEPATTERN24   = 88,
  739.     D3DRENDERSTATE_STIPPLEPATTERN25   = 89,
  740.     D3DRENDERSTATE_STIPPLEPATTERN26   = 90,
  741.     D3DRENDERSTATE_STIPPLEPATTERN27   = 91,
  742.     D3DRENDERSTATE_STIPPLEPATTERN28   = 92,
  743.     D3DRENDERSTATE_STIPPLEPATTERN29   = 93,
  744.     D3DRENDERSTATE_STIPPLEPATTERN30   = 94,
  745.     D3DRENDERSTATE_STIPPLEPATTERN31   = 95,
  746. } D3DRENDERSTATETYPE;
  747.  
  748. #define D3DRENDERSTATE_STIPPLEPATTERN(y) (D3DRENDERSTATE_STIPPLEPATTERN00 + (y))
  749.  
  750. typedef struct _D3DSTATE {
  751.     union {
  752.         D3DTRANSFORMSTATETYPE   dtstTransformStateType;
  753.         D3DLIGHTSTATETYPE       dlstLightStateType;
  754.         D3DRENDERSTATETYPE      drstRenderStateType;
  755.     };
  756.     union {
  757.         DWORD                   dwArg[1];
  758.         D3DVALUE                dvArg[1];
  759.     };
  760. } D3DSTATE, *LPD3DSTATE;
  761.  
  762. /*
  763.  * Operation used to load matrices
  764.  * hDstMat = hSrcMat
  765.  */
  766. typedef struct _D3DMATRIXLOAD {
  767.     D3DMATRIXHANDLE hDestMatrix;   /* Destination matrix */
  768.     D3DMATRIXHANDLE hSrcMatrix;   /* Source matrix */
  769. } D3DMATRIXLOAD, *LPD3DMATRIXLOAD;
  770.  
  771. /*
  772.  * Operation used to multiply matrices
  773.  * hDstMat = hSrcMat1 * hSrcMat2
  774.  */
  775. typedef struct _D3DMATRIXMULTIPLY {
  776.     D3DMATRIXHANDLE hDestMatrix;   /* Destination matrix */
  777.     D3DMATRIXHANDLE hSrcMatrix1;  /* First source matrix */
  778.     D3DMATRIXHANDLE hSrcMatrix2;  /* Second source matrix */
  779. } D3DMATRIXMULTIPLY, *LPD3DMATRIXMULTIPLY;
  780.  
  781. /*
  782.  * Operation used to transform and light vertices.
  783.  */
  784. typedef struct _D3DPROCESSVERTICES {
  785.     DWORD        dwFlags;    /* Do we transform or light or just copy? */
  786.     WORD         wStart;     /* Index to first vertex in source */
  787.     WORD         wDest;      /* Index to first vertex in local buffer */
  788.     DWORD        dwCount;    /* Number of vertices to be processed */
  789.     DWORD        dwReserved; /* Must be zero */
  790. } D3DPROCESSVERTICES, *LPD3DPROCESSVERTICES;
  791.  
  792. #define D3DPROCESSVERTICES_TRANSFORMLIGHT       0x00000000L
  793. #define D3DPROCESSVERTICES_TRANSFORM            0x00000001L
  794. #define D3DPROCESSVERTICES_COPY                 0x00000002L
  795. #define D3DPROCESSVERTICES_OPMASK               0x00000007L
  796.  
  797. #define D3DPROCESSVERTICES_UPDATEEXTENTS        0x00000008L
  798. #define D3DPROCESSVERTICES_NOCOLOR              0x00000010L
  799.  
  800.  
  801. /*
  802.  * Triangle flags
  803.  */
  804.  
  805. /*
  806.  * Tri strip and fan flags.
  807.  * START loads all three vertices
  808.  * EVEN and ODD load just v3 with even or odd culling
  809.  * START_FLAT contains a count from 0 to 29 that allows the
  810.  * whole strip or fan to be culled in one hit.
  811.  * e.g. for a quad len = 1
  812.  */
  813. #define D3DTRIFLAG_START                        0x00000000L
  814. #define D3DTRIFLAG_STARTFLAT(len) (len)         /* 0 < len < 30 */
  815. #define D3DTRIFLAG_ODD                          0x0000001eL
  816. #define D3DTRIFLAG_EVEN                         0x0000001fL
  817.  
  818. /*
  819.  * Triangle edge flags
  820.  * enable edges for wireframe or antialiasing
  821.  */
  822. #define D3DTRIFLAG_EDGEENABLE1                  0x00000100L /* v0-v1 edge */
  823. #define D3DTRIFLAG_EDGEENABLE2                  0x00000200L /* v1-v2 edge */
  824. #define D3DTRIFLAG_EDGEENABLE3                  0x00000400L /* v2-v0 edge */
  825. #define D3DTRIFLAG_EDGEENABLETRIANGLE \
  826.         (D3DTRIFLAG_EDGEENABLE1 | D3DTRIFLAG_EDGEENABLE2 | D3DTRIFLAG_EDGEENABLE3)
  827.         
  828. /*
  829.  * Primitive structures and related defines.  Vertex offsets are to types
  830.  * D3DVERTEX, D3DLVERTEX, or D3DTLVERTEX.
  831.  */
  832.  
  833. /*
  834.  * Triangle list primitive structure
  835.  */
  836. typedef struct _D3DTRIANGLE {
  837.     union {
  838.         WORD    v1;            /* Vertex indices */
  839.         WORD    wV1;
  840.     };
  841.     union {
  842.         WORD    v2;
  843.         WORD    wV2;
  844.     };
  845.     union {
  846.         WORD    v3;
  847.         WORD    wV3;
  848.     };
  849.     WORD        wFlags;       /* Edge (and other) flags */
  850. } D3DTRIANGLE, *LPD3DTRIANGLE;
  851.  
  852. /*
  853.  * Line strip structure.
  854.  * The instruction count - 1 defines the number of line segments.
  855.  */
  856. typedef struct _D3DLINE {
  857.     union {
  858.         WORD    v1;            /* Vertex indices */
  859.         WORD    wV1;
  860.     };
  861.     union {
  862.         WORD    v2;
  863.         WORD    wV2;
  864.     };
  865. } D3DLINE, *LPD3DLINE;
  866.  
  867. /*
  868.  * Span structure
  869.  * Spans join a list of points with the same y value.
  870.  * If the y value changes, a new span is started.
  871.  */
  872. typedef struct _D3DSPAN {
  873.     WORD        wCount; /* Number of spans */
  874.     WORD        wFirst; /* Index to first vertex */
  875. } D3DSPAN, *LPD3DSPAN;
  876.  
  877. /*
  878.  * Point structure
  879.  */
  880. typedef struct _D3DPOINT {
  881.     WORD        wCount;         /* number of points         */
  882.     WORD        wFirst;         /* index to first vertex    */
  883. } D3DPOINT, *LPD3DPOINT;
  884.  
  885.  
  886. /*
  887.  * Forward branch structure.
  888.  * Mask is logically anded with the driver status mask
  889.  * if the result equals 'value', the branch is taken.
  890.  */
  891. typedef struct _D3DBRANCH {
  892.     DWORD       dwMask;         /* Bitmask against D3D status */
  893.     DWORD       dwValue;
  894.     BOOL        bNegate;        /* TRUE to negate comparison */
  895.     DWORD       dwOffset;       /* How far to branch forward (0 for exit)*/
  896. } D3DBRANCH, *LPD3DBRANCH;
  897.  
  898. /*
  899.  * Status used for set status instruction.
  900.  * The D3D status is initialised on device creation
  901.  * and is modified by all execute calls.
  902.  */
  903. typedef struct _D3DSTATUS {
  904.     DWORD       dwFlags;        /* Do we set extents or status */
  905.     DWORD       dwStatus;       /* D3D status */
  906.     D3DRECT     drExtent;
  907. } D3DSTATUS, *LPD3DSTATUS;
  908.  
  909. #define D3DSETSTATUS_STATUS             0x00000001L
  910. #define D3DSETSTATUS_EXTENTS            0x00000002L
  911. #define D3DSETSTATUS_ALL        (D3DSETSTATUS_STATUS | D3DSETSTATUS_EXTENTS)
  912.  
  913. /*
  914.  * Statistics structure
  915.  */
  916. typedef struct _D3DSTATS {
  917.     DWORD        dwSize;
  918.     DWORD        dwTrianglesDrawn;
  919.     DWORD        dwLinesDrawn;
  920.     DWORD        dwPointsDrawn;
  921.     DWORD        dwSpansDrawn;
  922.     DWORD        dwVerticesProcessed;
  923. } D3DSTATS, *LPD3DSTATS;
  924.  
  925. /*
  926.  * Execute options.
  927.  * When calling using D3DEXECUTE_UNCLIPPED all the primitives 
  928.  * inside the buffer must be contained within the viewport.
  929.  */
  930. #define D3DEXECUTE_CLIPPED       0x00000001l
  931. #define D3DEXECUTE_UNCLIPPED     0x00000002l
  932.  
  933. typedef struct _D3DEXECUTEDATA {
  934.     DWORD       dwSize;
  935.     DWORD       dwVertexOffset;
  936.     DWORD       dwVertexCount;
  937.     DWORD       dwInstructionOffset;
  938.     DWORD       dwInstructionLength;
  939.     DWORD       dwHVertexOffset;
  940.     D3DSTATUS   dsStatus;       /* Status after execute */
  941. } D3DEXECUTEDATA, *LPD3DEXECUTEDATA;
  942.  
  943. /*
  944.  * Palette flags.
  945.  * This are or'ed with the peFlags in the PALETTEENTRYs passed to DirectDraw.
  946.  */
  947. #define D3DPAL_FREE     0x00    /* Renderer may use this entry freely */
  948. #define D3DPAL_READONLY 0x40    /* Renderer may not set this entry */
  949. #define D3DPAL_RESERVED 0x80    /* Renderer may not use this entry */
  950.  
  951. #if defined(__cplusplus)
  952. };
  953. #endif
  954.  
  955. #pragma pack()
  956.  
  957. #pragma option pop
  958. #endif /* _D3DTYPES_H_ */
  959.